package entities;

import menu.Settings;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;

import util.Vector2D;

public class SinusEnemy extends Enemy {

	private boolean initialized;
	private float amplitude;
	private float centerPoint;
	
	public SinusEnemy() throws SlickException {
		super("res/enemies/enemy04.png");
		image = image.getScaledCopy(70, 35);
		health = (int) (2 * Settings.getfactor());
		score = 20;
		destroyOffScreenY = false;
	}
	
	@Override
	public void update(GameContainer gc, int delta) {
		super.update(gc, delta);
		if (!initialized) {
			amplitude = random.nextBoolean() ? 100 : -100;
			if (getY() + amplitude >= 600 || getY() + amplitude <= 0) {
				amplitude = -amplitude;
			}
			initialized = true;
		}
		if (centerPoint == 0) {
			centerPoint = pos.getY() + (amplitude / 2);
		}
		acceleration = new Vector2D(0, centerPoint - pos.getY()).scale(10);
		
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	public void reset() {
		super.reset();
		setVelocity(new Vector2D(-100 - random.nextInt(75), 0));
		centerPoint = 0;
		initialized = false;
	}

}
